home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmsw.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  2.5 KB  |  117 lines

  1. #ifndef    H_RPMSW
  2. #define    H_RPMSW
  3.  
  4. /** \ingroup rpmio
  5.  * \file rpmio/rpmsw.h
  6.  */
  7.  
  8. /** \ingroup rpmio
  9.  */
  10. typedef unsigned long int rpmtime_t;
  11.  
  12. /** \ingroup rpmio
  13.  */
  14. typedef struct rpmsw_s * rpmsw;
  15.  
  16. /** \ingroup rpmio
  17.  */
  18. typedef struct rpmop_s * rpmop;
  19.  
  20. /** \ingroup rpmio
  21.  */
  22. struct rpmsw_s {
  23.     union {
  24.     struct timeval tv;
  25.     unsigned long long int ticks;
  26.     unsigned long int tocks[2];
  27.     } u;
  28. };
  29.  
  30. /** \ingroup rpmio
  31.  * Cumulative statistics for an operation.
  32.  */
  33. struct rpmop_s {
  34.     struct rpmsw_s    begin;    /*!< Starting time stamp. */
  35.     int            count;    /*!< Number of operations. */
  36.     size_t        bytes;    /*!< Number of bytes transferred. */
  37.     rpmtime_t        usecs;    /*!< Number of ticks. */
  38. };
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. /** Return benchmark time stamp.
  45.  * @param *sw        time stamp
  46.  * @return        0 on success
  47.  */
  48. /*@-exportlocal@*/
  49. /*@null@*/
  50. rpmsw rpmswNow(/*@returned@*/ rpmsw sw)
  51.     /*@globals internalState @*/
  52.     /*@modifies sw, internalState @*/;
  53. /*@=exportlocal@*/
  54.  
  55. /** Return benchmark time stamp difference.
  56.  * @param *end        end time stamp
  57.  * @param *begin    begin time stamp
  58.  * @return        difference in micro-seconds
  59.  */
  60. /*@-exportlocal@*/
  61. rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
  62.     /*@*/;
  63. /*@=exportlocal@*/
  64.  
  65. /** Return benchmark time stamp overhead.
  66.  * @return        overhead in micro-seconds
  67.  */
  68. /*@-exportlocal@*/
  69. rpmtime_t rpmswInit(void)
  70.     /*@globals internalState @*/
  71.     /*@modifies internalState @*/;
  72. /*@=exportlocal@*/
  73.  
  74. /** \ingroup rpmio
  75.  * Enter timed operation.
  76.  * @param op            operation statistics
  77.  * @param rc            -1 clears usec counter
  78.  * @return            0 always
  79.  */
  80. int rpmswEnter(/*@null@*/ rpmop op, ssize_t rc)
  81.     /*@globals internalState @*/
  82.     /*@modifies *op, internalState @*/;
  83.  
  84. /** \ingroup rpmio
  85.  * Exit timed operation.
  86.  * @param op            operation statistics
  87.  * @param rc            per-operation data (e.g. bytes transferred)
  88.  * @return            cumulative usecs for operation
  89.  */
  90. rpmtime_t rpmswExit(/*@null@*/ rpmop op, ssize_t rc)
  91.     /*@globals internalState @*/
  92.     /*@modifies op, internalState @*/;
  93.  
  94. /** \ingroup rpmio
  95.  * Sum statistic counters.
  96.  * @param to            result statistics
  97.  * @param from            operation statistics
  98.  * @return            cumulative usecs for operation
  99.  */
  100. rpmtime_t rpmswAdd(/*@null@*/ rpmop to, /*@null@*/ rpmop from)
  101.     /*@modifies to @*/;
  102.  
  103. /** \ingroup rpmio
  104.  * Subtract statistic counters.
  105.  * @param to            result statistics
  106.  * @param from            operation statistics
  107.  * @return            cumulative usecs for operation
  108.  */
  109. rpmtime_t rpmswSub(rpmop to, rpmop from)
  110.     /*@modifies to @*/;
  111.  
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115.  
  116. #endif    /* H_RPMSW */
  117.